#ifndef DLGMAIN_H
#define DLGMAIN_H

#include <QDialog>
#include <QTimer>
#include <QFile>
#include <QDir>
#include <QProcess>
#include <QThread>
#include <QSettings>
#include <QProcess>
#include <QSystemTrayIcon>
#include "tmcopyfileworker.h"


namespace Ui {
class DlgMain;
}

class DlgMain : public QDialog
{
    Q_OBJECT

public:
    explicit DlgMain(QWidget *parent = 0);
    ~DlgMain();

    void init();

    bool copyDirFiles(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
    bool removeFolderContent(const QString &folderDir);

    qint64 getFolderSize(QString folder);
    void checkDirIsExist(QString strDirName);
signals:
    void sig_extractDir(QString filePath, QString toDir);
    void sig_copyDir(QString fromDir, QString toDir);
private slots:
    void trayicon_activated(QSystemTrayIcon::ActivationReason reason);
    void slot_checkUpdate();

    void slot_extractDirSuccess(QStringList list);

    void slot_updateProgressBar();
    void on_btn_hide_clicked();

    void on_btn_exit_clicked();

private:
    Ui::DlgMain *ui;
    QString strRootDir;
    QDir *pDir;
    QTimer *m_prTimer;
    QProcess* m_pProcCmd;
    QFileInfoList fileList;
    QString zipFilePath;
    bool m_bIsExtractSuccess;
    int nIndex;
    qint64 nFileCount;

    QSettings *pr_setting;
    QString strDirPath;
    QString m_strUpdatePath;
    QString m_strTmpPath;

    QSystemTrayIcon* m_pSystemTray;

    TMCopyFileWorker *p_CopyFileWorker;
};

#endif // DLGMAIN_H
